<?
if (!defined('SMF'))
	die('Hacking attempt...');

global $smcFunc, $txt, $scripturl, $settings, $user_info;
global $dbtables, $sector_max;

// Verify user login, if CheckLogin() returns false return to the calling script/function
if (CheckLogin() == false)
	return;

BigTitle($txt['bnt_ewd_title']);

//-------------------------------------------------------------------------------------------------

// Pull player info.
$result = $smcFunc['db_query']('', '
	SELECT *
	FROM {raw:db_ships}
	WHERE user_id = {int:user_id}
	LIMIT 1',
	array(
		'db_ships' => $dbtables['ships'],
		'user_id' => $user_info['id'],
	)
);
$playerinfo = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);

srand((double)microtime()*1000000);

if ($playerinfo['dev_emerwarp'] > 0)
{
	$dest_sector = rand(0,$sector_max - 1);
	$update = $smcFunc['db_query']('', '
		UPDATE  {raw:db_ships}
		SET sector = {int:dest_sector},
			dev_emerwarp = dev_emerwarp - 1
		WHERE ship_id = {int:ship_id}',
		array(
			'db_ships' => $dbtables['ships'],
			'ship_id' => $playerinfo['ship_id'],
			'dest_sector' => $dest_sector
		)
	);
	log_move($playerinfo['ship_id'],$dest_sector);
	$txt['bnt_ewd_used'] = str_replace("[sector]", $dest_sector, $txt['bnt_ewd_used']);
	echo $txt['bnt_ewd_used'], '<br><br>';
}
else
	echo $txt['bnt_ewd_none'], '<br><br>';

TextMainMenu();

?>
